<template>
    <div>
        {{ ruleNewsForm }}
 
<el-form :model="ruleNewsForm" ref="ruleForm">
  <el-form-item label="标题">
    <el-input v-model="ruleNewsForm.title"></el-input>
  </el-form-item>
  <el-form-item label="内容">
    <WangEditor height="400" v-model="ruleNewsForm.content"></WangEditor>

  </el-form-item>
  <el-form-item label="公告照片">
    <UploadFile v-model="ruleNewsForm.picture"></UploadFile>

  </el-form-item>
  <el-form-item label="">
 <el-button type="primary" @click="onSubmit">提交</el-button>
  </el-form-item>
</el-form>
    </div>
</template>
<script setup lang='ts'>
import { addNews } from '@/apis/news/news';
import { News } from '@/apis/news/type';
import WangEditor from '@/components/editor/WangEditor.vue';
import UploadFile from '@/components/upload/UploadFile.vue';
import { dayjs } from 'element-plus';
import { reactive, toRaw } from 'vue';

const ruleNewsForm = reactive<News>({
    id: 0,
                title: "",
                picture: "",
                edituser:"" ,
                state: 1,
                type: 1,
                content: "",
                addtime:dayjs().format("YYYY-MM-DD HH:mm:ss"),
});

const onSubmit=async ()=>{

    console.log(toRaw(ruleNewsForm));

   const res=await addNews(ruleNewsForm);
    
}

 

 
</script>
<style scoped lang='less'></style>